package com.iteaj.iot.test;

import org.springframework.boot.context.event.ApplicationStartedEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.util.CollectionUtils;

import java.util.Map;
import java.util.concurrent.TimeUnit;

public class IotTestStartListener implements ApplicationListener<ApplicationStartedEvent> {

    @Override
    public void onApplicationEvent(ApplicationStartedEvent applicationStartedEvent) {

        new Thread(() -> {
            applicationStartedEvent.getApplicationContext().getBeanFactory()
                    .getBeanProvider(IotTestHandle.class).orderedStream().forEach(item -> {
                try {
                    item.start();
                    System.out.println("\n");
                    TimeUnit.SECONDS.sleep(3);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            });
        }).start();
    }
}
